//
//  SimpleDetailViewController.m
//  USB_Reader
//
//  Created by why on 15-3-23.
//  Copyright (c) 2015年 Tony_Wang. All rights reserved.
//

#import "SimpleDetailViewController.h"

@interface SimpleDetailViewController ()
@property (nonatomic, retain) UIWebView *myWebView;
@property (nonatomic, retain) NSMutableDictionary *dic;
@end

@implementation SimpleDetailViewController

- (void)dealloc
{
    [_myWebView release];
    [_dic release];
    [_model release];
    [super dealloc];
}

- (void)requestNetWorking
{
      [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
    
    AFHTTPRequestOperationManager *manger = [AFHTTPRequestOperationManager manager];
    NSString *strPath = [NSString stringWithFormat:@"http://api.yi18.net/top/show?id=%@", self.model.sNewsID];
    [manger GET:strPath parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
       
        
        NSMutableDictionary *dic = [responseObject objectForKey:@"yi18"];
        if (dic != nil) {
              [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
        }
        
        [ self.myWebView loadHTMLString:[dic objectForKey:@"message"]baseURL:nil];
        
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
           NSLog(@"%@", error);
    }];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self requestNetWorking];
    
    self.myWebView = [[UIWebView alloc] initWithFrame:self.view.bounds];
  
    [self.view addSubview:self.myWebView];
    
    [_myWebView release];
    
   
    
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
